package com.lz.football.module.guide.setting.view
{
	import com.common.stdlib.StringUtil;
	import com.global.GlobalDef;
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.GuideEvent;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import lz.controls.Alert;

	/**
	 *名字选择 
	 * @author lake
	 * 
	 */	
	public class NameSettingPanel extends GuideBaseSelectPanel
	{
		/**
		 *名字 
		 */		
		private var txtName :TextField;
		/**
		 *名字定义 
		 */		
		private var fnames  :Array;
		private var snames  :Array;
		private var tnames  :Array;
		
		public function NameSettingPanel()
		{
			super();
			var fStr :String = "天下,足球,足坛,最佳,体坛,足联,强力,黑暗,冷酷,冷漠,寂寞,午夜,流浪,超级,宇宙,绝地,恒大,曼联,皇马,巴萨,申花,鲁能,巴黎,拜仁,切尔西,巴西,德国,中国,意大利,法国,阿根廷,西班牙,德意志,英超,德甲,中超,意甲,西甲,法甲,爱情,梦幻,强力,德拉诺";
			fnames = fStr.split(",");
			var sStr :String = "制霸,第一,第二,第三,前十,大,小,超级,无敌,年度,的,一,老,强力,冠军,噬魂,失魂,无限,好,坏,幻,梦,萌,猛,飘,魔,战,巫,舞,神,之,二,遗忘,或,百大,十大,最佳,最,最优,最强,最猛,最真,真,假";
			snames = sStr.split(",");
			var tStr :String = "前锋,中场,后卫,门将,射手,金靴,门神,炮手,枪手,战神,战士,人,男,帅哥,靓妹,伤,爱,情,心,海,天,星,宝贝,妹,回忆,曾经,旋律,乐章,琴,青春,脉动,健将,小将,大将,元帅,国王,皇帝,7号,10号,18号,3号,9号,11号,庵,冠军,刀剑,传奇,传,纪,物语,龙";
			tnames = tStr.split(",");
		}
		/**
		 * 初始化
		 * @param view
		 * 
		 */		
		override public function initUI(view:Object=null):void
		{
			_symbolSkin = view as MovieClip;
			nextBtn = _symbolSkin.nextBtn;
			txtName = _symbolSkin.txtName;
			//txtName.text = "lzfb" + int(Math.random() * 99999);
			txtName.text = fnames[int(fnames.length * Math.random())] + snames[int(snames.length * Math.random())] + tnames[int(tnames.length * Math.random())];
			txtName.maxChars = 12;
			addEvtListener();
		}
		/**
		 *下一步 
		 * @param e
		 * 
		 */		
		override protected function nextHandler(e :MouseEvent):void
		{
			var clubName :String = txtName.text;
			clubName = clubName.replace(/\ /g,"");
			clubName = StringUtil.trim(clubName);
			// /^[\u4e00-\u9fa5a-z1-9]+$/gi //输入中文数字字母
			// /[<>\\\/_"',.]/g  //匹配特定字符
			var pattern:RegExp = /[<>\\\/_"',.]/g;
			var result :Object = pattern.exec(clubName);
			if(result) 
			{
				Alert.show("俱乐部名字有非法字符","",Alert.YES,GlobalDef.GameStage);
				return;
			}
			if(StringUtil.isContainsFilterWord(clubName))
			{
				Alert.show("非法俱乐部名字","",Alert.YES,GlobalDef.GameStage);
				return;
			}
			if(clubName==null || clubName == "")
			{
				Alert.show("请输入俱乐部名字!","",Alert.YES,GlobalDef.GameStage);
				return;
			}
			AppEventDispatcher.getInstance().dispatchEvent(new GuideEvent(GuideEvent.NAME_SELECT,clubName));
		}
	}
}